#ifndef ELLOOP_SINGLETON_H
#define ELLOOP_SINGLETON_H

template <class T>
class ELSingleton {
	static T* mInstance;
public:
	static T* getInstance();
	static void free();
protected:
	ELSingleton() {}
	virtual ~ELSingleton() {};
	ELSingleton<T>& operator=(const ELSingleton<T>& other);
	ELSingleton(const ELSingleton<T>& other);
};

template <class T> T* ELSingleton<T>::mInstance = 0;

template <class T> T* ELSingleton<T>::getInstance() {
	if (!mInstance) {
		mInstance = new T();
	}
	return mInstance;
}

template <class T> void ELSingleton<T>::free() {
	if (mInstance) {
		delete mInstance;
		mInstance = 0;
	}
}

#endif